import request from '@/config/axios'

// 公函 VO
export interface BaseOfficialLetterVO {
  id: number // 主键
  theme: string // 主题
  startDate: Date // 开始日期
  endDate: Date // 结束日期
  fileExists: number // 附件(97:有/98:无)
  content: string // 公函内容
  remark: string // 备注
  status: number // 状态(草稿:0；审核中:1；审核通过:2；审核驳回:3)
  detailData: any // 数据
  fileData: any // 数据
  deptId: number // 部门id
}

// 更新公函查看次数 VO
export interface BaseOfficialLetterDetailVO {
  id: number // 主键
  officialLetterId: number // 公函管理id
  totalViewNum: number // 查看总次数
  status: number // 状态(查看状态(0:未查看；1:已查看))
}

// 批量提交公函 VO
export interface BaseOfficialLettersVO {
  ids: number[] // 公函管理id
  status: number // 状态(草稿:0；审核中:1；审核通过:2；审核驳回:3)
}

// 关联公函人员 VO
export interface BaseOfficialLetterDetailsVO {
  id: number // 公函管理id
  officialLetterId: number // 公函管理id
  detailData: any // 数据
  status: number // 状态(查看状态(0:未查看；1:已查看))
}

// 公函审批记录 VO
export interface BaseOfficialLetterRecordVO {
  id: number // 主键id
  officialLetterId: number // 公函管理id
  approveOpinion: String // 数据
  approveResult: number // 状态(查看状态(0:未查看；1:已查看))
}

// 公函 API
export const BaseOfficialLetterApi = {
  // 查询公函分页
  getBaseOfficialLetterPage: async (params: any) => {
    return await request.get({ url: `/infra/base-official-letter/page`, params })
  },

  // 查询公函详情
  getBaseOfficialLetter: async (id: number) => {
    return await request.get({ url: `/infra/base-official-letter/get?id=` + id })
  },

  // 新增公函
  createBaseOfficialLetter: async (data: BaseOfficialLetterVO) => {
    return await request.post({ url: `/infra/base-official-letter/create`, data })
  },

  // 修改公函
  updateBaseOfficialLetter: async (data: BaseOfficialLetterVO) => {
    return await request.put({ url: `/infra/base-official-letter/update`, data })
  },

  // 删除公函
  deleteBaseOfficialLetter: async (id: number) => {
    return await request.delete({ url: `/infra/base-official-letter/delete?id=` + id })
  },

  // 导出公函 Excel
  exportBaseOfficialLetter: async (params) => {
    return await request.download({ url: `/infra/base-official-letter/export-excel`, params })
  },

  // 获取公函管理-接收人员列表信息
  getLetterUserList: async (id: number) => {
    return request.get({ url: `/infra/base-official-letter/getLetterUserList?officialLetterId=` + id })
  },

  // 获取公函管理-公函附件列表信息
  getLetterFileList: async (id: number) => {
    return request.get({ url: `/infra/base-official-letter/getLetterFileList?officialLetterId=` + id })
  },

  // 有效、无效公函-查询公函分页
  getEffectOfficialLetterPage: async (params: any) => {
    return await request.get({ url: `/infra/base-official-letter/getEffectOfficialLetterPage`, params })
  },

  // 公函审批-查询待审批和已审批公函分页
  getInvalidOfficialLetterPage: async (params: any) => {
    return await request.get({ url: `/infra/base-official-letter/getInvalidOfficialLetterPage`, params })
  },

  // 修改公函
  updateLetterDetail: async (data: BaseOfficialLetterDetailVO) => {
    return await request.put({ url: `/infra/base-official-letter/updateLetterDetail`, data })
  },

  // 修改公函
  submitOfficialLetter: async (data: BaseOfficialLettersVO) => {
    return await request.put({ url: `/infra/base-official-letter/submitOfficialLetter`, data })
  },

  // 更新公函明细
  updateOfficialDetail: async (data: BaseOfficialLetterDetailsVO) => {
    return await request.put({ url: `/infra/base-official-letter/updateOfficialDetail`, data })
  },

  // 新增公函审批记录
  createBaseOfficialRecord: async (data: BaseOfficialLetterRecordVO) => {
    return await request.post({ url: `/infra/base-official-letter/createBaseOfficialRecord`, data })
  },

  // 获取公函管理-公函审批列表信息
  getLetterRecordsList: async (id: number) => {
    return request.get({ url: `/infra/base-official-letter/getLetterRecordsList?officialLetterId=` + id })
  }

}
